/**
 * 
 */
package hu.gbalage.owl.editor;

import java.net.URI;

import hu.gbalage.owl.ConfiguredOWLReasoner;
import hu.gbalage.owl.editor.internal.IFileOWLInputSource;

import org.eclipse.ui.IFileEditorInput;
import org.semanticweb.owl.apibinding.OWLManager;
import org.semanticweb.owl.inference.OWLReasoner;
import org.semanticweb.owl.inference.OWLReasonerException;
import org.semanticweb.owl.model.OWLClass;
import org.semanticweb.owl.model.OWLOntology;
import org.semanticweb.owl.model.OWLOntologyCreationException;
import org.semanticweb.owl.model.OWLOntologyManager;

/**
 * @author balage
 *
 */
public class OWLEditorManager {

	public static final URI owlThingURI = URI.create("http://www.w3.org/2002/07/owl#Thing");
	public static final URI owlNothingURI = URI.create("http://www.w3.org/2002/07/owl#Nothing");
	
	OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
	
	OWLOntology ontology = null;
	
	OWLReasoner reasoner = ConfiguredOWLReasoner.createReasoner(manager);
	
	final IFileEditorInput input;
	
	public OWLEditorManager(IFileEditorInput input){
		this.input = input;
		try {
			ontology = manager.loadOntology(new IFileOWLInputSource(input.getFile()));
			reasoner.loadOntologies(manager.getOntologies());
		} catch (OWLOntologyCreationException e) {
			e.printStackTrace();
		} catch (OWLReasonerException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	public OWLOntologyManager getManager(){
		return manager;
	}
	
	public OWLClass getThing(){
		return manager.getOWLDataFactory().getOWLClass(owlThingURI);
	}
	
	public OWLClass getNothing(){
		return manager.getOWLDataFactory().getOWLClass(owlNothingURI);
	}
	
	public OWLOntology getOntology(){
		return ontology;
	}
	
	public OWLReasoner getReasoner(){
		return reasoner;
	}
	
	public void save(){
		//manager.s
	}
	
}
